@extends('admin::layouts.master')
@section('title')
    订单列表
@endsection
@section('tab')

    <div class="layui-fluid">
        <div class="layui-row">
            <form class="layui-form ">
                {{csrf_field()}}
                {{hi_form_hidden('id',$info->id)}}
                <div class="layui-form-item">
                    <label for="name" class="layui-form-label">
                        <span class="x-red">*</span>公告标题
                    </label>
                    <div class="layui-input-inline" style="width: 300px;">
                        <input type="text" id="name" name="title" placeholder="请输入标题" value="{{$info->title}}" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item layui-form-text">
                    <label for="desc" class="layui-form-label">
                        <span class="x-red">*</span>公告内容
                    </label>
                    <div class="layui-input-block" style="width: 300px;">
                        <textarea placeholder="请输入内容" id="desc" lay-verify="required" name="content" class="layui-textarea">{{$info->content}}</textarea>
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">
                        <span class="x-red">*</span>请选择范围
                    </label>
                    <div class="layui-input-block" style="width: 300px;">
                        <input type="text" class="layui-input" name="times" lay-verify="required" value="{{$info->times}}" id="test16" placeholder="开始 到 结束">
                    </div>
                </div>

                <div class="layui-form-item">
                      <label class="layui-form-label"><span class="x-red">*</span>公告类型</label>
                      <div class="layui-input-block">
                        @foreach($arr as $key => $value)
                            <input type="checkbox" name="type[]" @if( in_array($key,$info['types']) ) checked="" @endif value="{{$key}}" lay-skin="primary"  title="{{$value}}" >
                        @endforeach
                      </div>
                </div>

                <div class="layui-form-item">
                    <div class="layui-form-label" >
                        <button class="layui-btn" lay-submit="" lay-filter="btn_edit">确认提交</button>
                    </div>
                </div>
            </form>
        </div>
    </div>



@endsection

@section('tab_js')

    <script>
        layui.use(['form', 'layer', 'jquery','laydate'], function () {
            $ = layui.jquery;
            var form = layui.form,
                layer = layui.layer;
            var laydate = layui.laydate;

                laydate.render({
                    elem: '#test16'
                    ,type: 'datetime'
                    ,range: '至'
                    ,format: 'yyyy-M-d H:m:s'
                });

            //监听提交
            form.on('submit(btn_edit)', function (data) {
                $.ajax({
                    url: js_url('admin-notice-update'),
                    type: 'post',
                    data: data.field,
                    dataType: "json",
                    success: function (result) {
                        if (result.state === 0) {
                            layer.msg(result.msg, {time: 600, icon: 6}, function () {
                                //关闭当前frame
                                xadmin.close();
                                // 可以对父窗口进行刷新
                                xadmin.father_reload();
                            });
                        } else {
                            layer.msg(result.msg, {time: 2000, icon: 5});
                        }
                    }
                });
                return false;
            });
        });
    </script>




@endsection